package mysql

import (
	"doctor-medicine-system/usersrpc/usersrpc"
	"gorm.io/gorm"
)

type Medicine struct {
	gorm.Model
	Name     string `gorm:"type:varchar(30)"`
	Content  string `gorm:"type:varchar(30)"`
	From     string `gorm:"type:varchar(100)"`
	Message  string `gorm:"type:varchar(100)"`
	Sign     string `gorm:"type:varchar(30)"`
	DoctorId int    `gorm:"type:int(11)"`
}

func (m *Medicine) MedicineAdd(db *gorm.DB) error {
	return db.Debug().Create(m).Error
}
func MedicineList(db *gorm.DB, list []*usersrpc.MedicineList) []*usersrpc.MedicineList {
	db.Debug().Model(&Medicine{}).Select(
		"medicines.id AS medicine_id",
		"name",
		"content",
		"from",
		"message",
		"sign").
		Find(&list)
	return list
}
